import axios,{type AxiosInstance,type AxiosRequestConfig, type AxiosResponse} from "axios";
import { showNotify } from "vant";
let instance:AxiosInstance= axios.create({
    baseURL:"/api",
    timeout:5000
})

instance.interceptors.request.use((config:AxiosRequestConfig)=>{
    let token =localStorage.getItem("token");
    if(token){
        (config.headers as any).token=token;
    }
    return config
})

instance.interceptors.response.use((res:AxiosResponse)=>{
   showNotify({ 
    // type: res.data.code==="200"?"success":"error",
    type:"success",
    message: `${res.data.message}`,
    duration:1000
 });
  return res;
})
export default instance